<?php

namespace App\Http\Requests;
use App\Exceptions\ApiException;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Contracts\Validation\Validator;
class NewWebsiteYuyueRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'=>'required',
            'mobile'=>'required',
            'start_time'=>'required',
            'end_time'=>'required',
            'workshop_id'=>'required',

        ];
    }
    public function messages()
    {
        return [

            'name.required'=>'请输入申请人名称',
            'mobile.required'=>'请输入手机号',
            'start_time.required'=>'请选择时间段',
            'end_time.required'=>'请选择时间段',
            'workshop_id.required'=>'请选择盘源'
        ];
    }
    protected function failedValidation(Validator $validator) {
        $error= $validator->errors()->all();
        throw new ApiException($error[0]);
    }
}
